<template>
    <el-card class="product-card" shadow="hover" :body-style="{ padding: '10px' }">
        <router-link :to="`/product/${product.id}`">
            <el-image
                :src="product.image"
                fit="cover"
                class="product-image"
                lazy
            />
        </router-link>

        <div class="product-info">
            <div class="title">
                <router-link :to="`/product/${product.id}`">{{ product.title }}</router-link>
            </div>

            <div class="price-area">
                <span class="current-price">¥{{ product.price }}</span>
                <span class="original-price" v-if="product.originalPrice">¥{{ product.originalPrice }}</span>
                <span class="sold">已售{{ product.sold }}件</span>
            </div>

            <div class="shop-info">
                <span class="shop-name">{{ product.shop }}</span>
                <span class="location">{{ product.location }}</span>
            </div>
        </div>
    </el-card>
</template>

<script>
export default {
    props: {
        product: {
            type: Object,
            required: true
        }
    }
}
</script>

<style scoped>
.product-card {
    margin-bottom: 20px;
    border-radius: 4px;
    overflow: hidden;
    transition: transform 0.3s;
    border: none;
}

.product-card:hover {
    transform: translateY(-5px);
}

.product-image {
    width: 100%;
    height: 200px;
    border-radius: 4px;
}

.product-info {
    padding: 10px 0;
}

.title {
    height: 40px;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.4;
}

.title a {
    color: #333;
    text-decoration: none;
}

.title a:hover {
    color: var(--primary-color);
}

.price-area {
    margin: 8px 0;
    display: flex;
    align-items: center;
}

.current-price {
    color: var(--primary-color);
    font-size: 18px;
    font-weight: bold;
    margin-right: 8px;
}

.original-price {
    color: #999;
    font-size: 12px;
    text-decoration: line-through;
    margin-right: 10px;
}

.sold {
    color: #999;
    font-size: 12px;
}

.shop-info {
    display: flex;
    justify-content: space-between;
    color: #666;
    font-size: 12px;
}

.shop-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
</style>